package nowcoder.huawei;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.*;

/**
 * @author wuguojian
 * @description
 * https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
 **/
public class HJ27 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new FileReader("input/nowcoder_huawei/HJ27.txt"));
//        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            List<String> brothers = new ArrayList<String>();
            int n = in.nextInt();
            String[] words = new String[n];
            for (int i = 0; i < n; i++) {
                words[i] = in.next();
            }
            String key = in.next();
            String k = getAscWord(key);
            for (int i = 0; i < n; i++) {
                if(key.equals(words[i])){
                    continue;
                }
                if(k.equals(getAscWord(words[i]))){
                    brothers.add(words[i]);
                }
            }
            int index = in.nextInt();
            System.out.println(brothers.size());
            if(brothers.size() >= index) {
                Collections.sort(brothers);
                System.out.println(brothers.get(index-1));
            }
        }
    }

    private static String getAscWord(String b){
        char[] chars = b.toCharArray();
        ArrayList<String> s = new ArrayList<String>();
        for (char aChar : chars) {
            s.add(String.valueOf(aChar));
        }
        Collections.sort(s);
        StringBuilder sb = new StringBuilder();
        for (String s1 : s) {
            sb.append(s1);
        }
        return sb.toString();
    }
}
